/*
 * @Author: wangdian
 * @Date: 2023-06-15 13:51:03
 * @LastEditors: wangdian
 * @LastEditTime: 2023-06-15 15:25:42
 * @Description: file content
 * @FilePath: \koa\app.js
 */
const koa = require('koa');  //引入koa
const Router = require('koa-router');  //引入koa路由

const app = new koa();  //实例一个koa
const router = new Router({ prefix: '/api' }); //prefix是设置一个路由前缀

router.get('/', async ctx => {  //页面显示用get请求方式
    ctx.body = 'Hello Koa!!!';
})

app.use(router.routes())  //引入路由中间件
    .use(router.allowedMethods());

app.listen(3000, () => {
    console.log('正在监听3000端口号！');
})